package org.brownflat.dbinit.oracle;

import org.brownflat.dbinit.upgrade.Upgrade;
import org.brownflat.dbinit.upgrade.UpgradeStatement;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>&copy Rupert Jones 2012</p>
 *
 * @author rup
 */
public class OracleZeroUpgrade implements Upgrade {

    private String patchTable = "DB_INIT_PATCHES";

    @Override
    public int getSequence() {
        return 0;
    }

    @Override
    public List<UpgradeStatement> getSql() {
        List<UpgradeStatement> statements = new ArrayList<UpgradeStatement>();
        statements.add(new UpgradeStatement("CREATE TABLE " + patchTable + " (LAST_PATCH VARCHAR(255), APPLIED TIMESTAMP DEFAULT SYSDATE NOT NULL);"));
        statements.add(new UpgradeStatement("INSERT INTO " + patchTable + " (LAST_PATCH) VALUES (0);COMMIT;"));
        return statements;
    }

    @Override
    public String getName() {
        return "oracle initial version";
    }

    public void setPatchTable(String patchTable) {
        this.patchTable = patchTable;
    }
}
